<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('标签列表')" />
</head>
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="role-form">
					<div class="select-list">
						<ul>
							<li>
								标签名称：<input type="text" name="tagName"/>
							</li>
							<li>
								权限字符：<input type="text" name="perms"/>
							</li>
							<li>
								创建人：<input type="text" name="createBy"/>
							</li>
							<li>
								标签状态：<select name="visible" th:with="type=${@dict.getType('cms_tag_visible')}">
									<option value="">所有</option>
									<option  th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>
							<li class="select-time">
								<label>创建时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
		
			<div class="btn-group-sm" id="toolbar" role="group">
				<div class="btn-group" shiro:hasPermission="cms:tag:edit">
					<button data-toggle="dropdown" class="btn btn-primary dropdown-toggle">状态设置 <span class="caret"></span>
					</button>
					<ul class="dropdown-menu" id="tagVisible" th:with="type=${@dict.getType('cms_tag_visible')}">
						<li  th:each="dict : ${type}"  th:data-id="${dict.dictValue}" ><a href="javascript:void(0)" th:text="${dict.dictLabel}"></a></li>
					</ul>
				</div>
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="cms:tag:add">
	                <i class="fa fa-plus"></i> 新增
	            </a>
	            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="cms:tag:edit">
		            <i class="fa fa-edit"></i> 修改
		        </a>
				<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="cms:tag:remove">
		            <i class="fa fa-remove"></i> 删除
		        </a>
		        <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="cms:tag:export">
		            <i class="fa fa-download"></i> 导出
		        </a>
	        </div>
	        
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table"></table>
			</div>
		</div>
	</div>
	<th:block th:include="include :: footer" />
	<script th:inline="javascript">
		var editFlag = [[${@permission.hasPermi('cms:tag:edit')}]];
		var removeFlag = [[${@permission.hasPermi('cms:tag:remove')}]];
		var prefix = ctx + "cms/tag";
		$(function() {
		    var options = {
		        url: prefix + "/list",
		        createUrl: prefix + "/add",
		        updateUrl: prefix + "/edit/{id}",
		        removeUrl: prefix + "/remove",
		        exportUrl: prefix + "/export",
		        sortName: "tagName",
		        modalName: "内容标签",
		        columns: [{
		            checkbox: true
		        },
		        {
		            field: 'tagId',
		            title: '标签编号'
		        },
		        {
		            field: 'tagName',
		            title: '标签名称',
		            sortable: true
		        },
		        {
		            field: 'perms',
		            title: '权限字符',
		            sortable: true
		        },
		        {
		            field: 'tagUrl',
		            title: '标签地址'
		        },
					{
						field: 'tagIco',
						title: '标签图标'
					},
		        {
					field: 'visible',
		        	title: '标签状态',
		        	align: 'center',
					formatter: function(value, row, index) {
							return $.table.selectDictLabel([[${@dict.getType('cms_tag_visible')}]], value);
						}
		        },
				{
						field: 'createBy',
						title: '创建人',
						sortable: true
				},
		        {
		            field: 'createTime',
		            title: '创建时间',
		            sortable: true
		        },
					{
						field: 'updateBy',
						title: '创建人',
						sortable: true
					},
				{
						field: 'updateTime',
						title: '更新时间',
						sortable: true
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		                var actions = [];
		                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.tagId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
		                actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.tagId + '\')"><i class="fa fa-remove"></i>删除</a> ');
		                return actions.join('');
		            }
		        }]
		    };
		    $.table.init(options);
		});

		/*文章顶置下拉框点击事件*/
		$('#tagVisible>li').click(function(e) {
			//获取选中行数据
			var pam={},tagIds=[],chooseData =$("#bootstrap-table").bootstrapTable('getSelections');
			pam.visible=$(this).attr("data-id");
			if (chooseData.length>0)
			{$.each(chooseData,function (index,ele) {
				tagIds.push(ele.tagId);
			});
				pam.tagIds=tagIds.join();

				$.modal.confirm("确认要修改选的标签状态吗？", function() {
					$.operate.post(prefix + "/editTagVisible", pam);
				})
			}
			else{
				$.modal.alert("请至少选择一项");

			}
		});
	</script>
</body>
</html>